<template>
  <el-form-item v-show="isShow" prop="opa" :label="i18nt('designer.setting.opa')">
    <el-slider v-model="opa" size="small" :min="0" :max="255" :step="1" :disabled="disabled" />
  </el-form-item>
</template>

<script>
export default {
  name: 'OpaEditor',
  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
    disabled: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    opa: {
      get() {
        return this.optionModel['opa']
      },

      set(newValue) {
        //if ((!newValue && (newValue !== 0)) || isNaN(newValue)) {
        if (newValue === undefined || newValue === null || isNaN(newValue)) {
          this.optionModel.opa = 255
        } else {
          this.optionModel.opa = Number(newValue)
        }
      }
    },
    isShow() {
      // 当组件为staticText, 并且isSetSize为false时，不显示
      if (this.selectedWidget && this.selectedWidget.type === 'staticText') {
        return false
      }

      return true
    }
  }
}
</script>

<style scoped></style>
